<template>
  <div>
    <!-- 单一根，指令才能生效，必须 v-modaldrag --->

    <el-form :model="department" ref="departmentForm" >


      <el-row :gutter="formGutter">

        <el-col :span="24"><el-form-item label="部门名称" name="name" ><el-input v-model:value="department.name" readonly :input-style="underlineElInputStyle" /></el-form-item></el-col>



        <el-col :span="24"><el-form-item label="上级部门ID" name="parentId" ><el-input v-model:value="department.parentId" readonly :input-style="underlineElInputStyle" /></el-form-item></el-col>

      </el-row>

      <el-row :gutter="formGutter">

        <el-col :span="24"><el-form-item label="部门类型" name="administrativeCategory" ><el-input v-model:value="department.administrativeCategory" readonly :input-style="underlineElInputStyle" /></el-form-item></el-col>



        <el-col :span="24"><el-form-item label="所在地址" name="addr" ><el-input v-model:value="department.addr" readonly :input-style="underlineElInputStyle" /></el-form-item></el-col>

      </el-row>

      <el-row :gutter="formGutter">

        <el-col :span="24"><el-form-item label="备注" name="remarks" ><el-input type='textarea' v-model="department.remarks" readonly :autosize="true" :input-style="underlineElInputStyle" autosize/></el-form-item></el-col>



        <el-col :span="24"><el-form-item label="顺序号" name="ordnum" ><el-input v-model:value="department.ordnum" readonly :input-style="underlineElInputStyle" /></el-form-item></el-col>

      </el-row>
    </el-form>


  </div>
</template>

<script lang="ts" setup>
/*
 * @author: user
 * @date: 2021-11-24 14:49:54
 * @template: dayu-code-builder
*/
import { onMounted, reactive, computed } from 'vue'
import {underlineElInputStyle} from '@/utils/constants';
import { Department, departmentService } from '@/api/demo/DepartmentService'
import { IForm, formColGutter } from '@/common/FormModal'

const props = defineProps({
  id: Number
});
const formGutter = formColGutter;
/** 接口数据（和接口返回数据对应） */
const departmentData = reactive({department:<Department>{}, codeTypes:{}, nameTypes:{}});
/** 表单数据 */
const department = computed(() => departmentData.department);

/** 获取表单数据 */
async function getFormData() {
  if (!props.id) return;
  try {
    let response: any = await departmentService.getDepartmentBO(props.id as number);
    departmentData.department = response.data.data || {};
    departmentData.codeTypes = response.data.codeTypes;
    departmentData.nameTypes = response.data.nameTypes;
  } catch (ex: any) {
    console.error("await error");
    console.error(ex);
  }
}

onMounted(() => {
  getFormData();
});


</script>

<style scoped>

</style>